﻿Imports System.Collections.ObjectModel
Imports System.Text
Imports FL_8x0.FL_800.Model

Namespace FL_8x0.Common

    Partial Public Module SystemData

        Public Const OperateCmd = "OperateCmd"
        Public Const ReadPressureCmd = "ReadPressureCmd"
        Public Const ReadGroupCmd = "ReadGroupCmd"
        Public Const ReadGroupExtCmd = "ReadGroupExtCmd"
        Public Const ReadResultCmd = "ReadResultCmd"
        Public Const ReadWaveCmd = "ReadWaveCmd"
        Public Const WriteGroupCmd = "WriteGroupCmd"
        Public Const SwitchGroupCmd = "SwitchGroupCmd"
        Public Const WriteGroupExtCmd = "WriteGroupExtCmd"
        Public Const WriteSNCmd = "WriteSNCmd"
        Public Const WriteClearCmd = "WriteClearCmd"

        Public Const Model_830 = "FL_830"
        Public Const Model_800 = "FL_800"
        Public Const Model_800MS = "FL_800MS"

        Public ModelList As New List(Of String) From {Model_800, Model_800MS, Model_830}

        Public Const Version_800_113 = "1.13及以下"
        Public Const Version_800_114_126 = "1.14至1.26"
        Public Const Version_800_127 = "1.27及以上"

        Public Versions_800 = New ObservableCollection(Of String) From {Version_800_113, Version_800_114_126, Version_800_127}

        Public Modes_800 = New ObservableCollection(Of String) From {"800-M0", "800-M1", "800-M4"}
        Public Modes_800MS = New ObservableCollection(Of String) From {"800MS-M0", "800MS-M1", "800MS-M3"}

        '                                       0       1      2       3         4       5         6       7       8        9         10        11    12
        Public g_strPress_800 As String() = {"预热", "准备", "延时", "充气1", "充气2", "平衡1", "平衡2", "检测", "排气", "BUBL", "Master", "CAL1", "CAL2", "等待排气"}
        Public g_strPress_800MS As String() = {"预热", "准备", "延时", "充气", "平衡2", "小漏检测", "大漏检测", "排气", "BUBL", "Master", "CAL2"}


        Public g_strCol_800 As String() = {"序号", "组号", "日期时间", "产品编码", "时间延时", "时间充气1", "时间充气2", "时间平衡1", "时间平衡2", "时间检测", "时间排气", "检测结果", "泄漏单位", "判定"}
        Public g_strCol_800MS As String() = {"序号", "组号", "日期时间", "产品编码", "时间延时", "时间充气", "时间平衡", "时间小漏检测", "时间大漏检测", "时间排气", "小漏结果", "大漏结果", "小漏单位", "判定"}

        Public g_udt800 As New GroupModel

        Public Machine As String = Model_830

        Public Version As String = Version_800_113

        Public strLink As String = ""

        Public udtFl800 As SerialPortServer = New SerialPortServer

        Public g_udtFL800Sync As SerialPortServerSync = New SerialPortServerSync

        Public g_strResult_800 As String() = {"报告号", "产品号", "产品名称", "产品型号", "产品编码", "记录号", "日期时间", "检测结果", "泄漏量感度", "泄漏量单位", "测试压单位", '"充气2结束差压(Pa)", "平衡2结束差压(Pa)",
            "结果判定", "使用组号", "时间_延时", "时间_充气1", "时间_充气2", "时间_平衡1", "时间_平衡2", "时间_检测", "时间_等待排气", "时间_排气", "时间_基准检测", "时间感度", "前导压标准", "2NG", "NG上限", "NG下限", "MNG上限", "MNG下限",
            "前导压上限", "前导压下限", "测试压标准", "测试压上限", "测试压下限", "被测物容积(mL)", "基准物容积(mL)", "Master模式", "输出模式", "串口输出模式", "气缸控制模式",
            "SV5Mode", "SV6Mode", "SV7Mode", "SV8Mode", "中途判定模式", "前导压DAC", "测试压DAC"}


        Public g_strResult_800MS As String() = {"报告号", "产品号", "产品名称", "产品型号", "产品编码", "记录号", "日期时间", "小漏结果", "大漏结果", "泄漏量感度", "泄漏量单位", "测试压单位",
            "结果判定", "使用组号", "时间_延时", "时间_充气", "时间_平衡", "时间_小漏检测", "时间_大漏检测", "时间_排气", "时间感度", "SNG上限", "SNG下限", "LNG上限", "LNG下限",
             "测试压标准", "测试压上限", "测试压下限", "Master模式", "输出模式", "串口输出模式", "气缸控制模式", "SV5Mode", "SV6Mode", "SV7Mode", "SV8Mode"}


        Public Function BCC(ByVal str As String) As Byte
            If str = "" Then
                Return 0
            End If

            Dim bytes() = Encoding.ASCII.GetBytes(str)
            Dim result = 0
            For i = 0 To bytes.Length - 1
                result = result Xor bytes(i)
            Next
            Return result
        End Function

    End Module
End Namespace